package it.gma.torero.operator;

import it.gma.torero.operand.Operand;


/**
 * In logic and mathematics, or is a truth-functional operator also known as
 * (inclusive) <a href="http://en.wikipedia.org/wiki/Logical_disjunction">disjunction</a> and alternation. The logical connective that
 * represents this operator is also known as "or", and produces a result of true
 * whenever one or more of its operands are true. For example, in this context,
 * "A or B" is true if A is true, or if B is true, or if both A and B are true.
 * In grammar, or is a coordinating conjunction. An operand of a disjunction is
 * called a disjunct.
 * 
 * @author giordano
 * 
 */
public class OrOperator extends AbstractBooleanOperator {

	

	public OrOperator(Operand operand1, Operand operand2) {
		super(operand1, operand2);
	}

	public boolean evaluate() {
		
		if (operand1.getValue() == null || operand2.getValue() == null) {
			throw new RuntimeException("Operands value cannot be null");
		}
		
		return ((Boolean)operand1.getValue()) || ( (Boolean) operand2.getValue() );
	}

	@Override
	public String toString() {
		return "(" + operand1 + " || " + operand2 + ")";
	}

}
